package com.cskaoyan.service;

import com.cskaoyan.bean.Feedback;
import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.FeedbackMapper;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author: yudefu
 * @date 2021年06月08日  14:01
 * @description: 反馈模块
 */
@Service
public class WxFeedbackServiceImpl implements WxFeedbackService{

    @Autowired
    FeedbackMapper feedbackMapper;

    @Override
    public int submitFeedback(Feedback feedback) {

        User user = (User) SecurityUtils.getSubject().getPrincipal();

        if (user == null) {
            return 0;
        }

        feedback.setId(0);
        feedback.setUserId(user.getId());
        feedback.setUsername(user.getUsername());
        feedback.setStatus(0);
        feedback.setAddTime(new Date());
        feedback.setUpdateTime(new Date());
        feedback.setDeleted(false);

        int insert = feedbackMapper.insert(feedback);


        return insert;
    }
}
